//
// CShadowPolyReceiver.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CVector;

public class CShadowPolyReceiver {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CShadowPolyReceiver(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CShadowPolyReceiver obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CShadowPolyReceiver(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CShadowPolyReceiver(long quadGridSize, float quadGridCellSize) {
    this(nel3dJNI.new_CShadowPolyReceiver__SWIG_0(quadGridSize, quadGridCellSize), true);
  }

  public CShadowPolyReceiver(long quadGridSize) {
    this(nel3dJNI.new_CShadowPolyReceiver__SWIG_1(quadGridSize), true);
  }

  public CShadowPolyReceiver() {
    this(nel3dJNI.new_CShadowPolyReceiver__SWIG_2(), true);
  }

  public long addTriangle(CTriangle tri) {
    return nel3dJNI.CShadowPolyReceiver_addTriangle(swigCPtr, this, CTriangle.getCPtr(tri), tri);
  }

  public void removeTriangle(long id) {
    nel3dJNI.CShadowPolyReceiver_removeTriangle(swigCPtr, this, id);
  }

  public void render(IDriver drv, CMaterial shadowMat, CShadowMap shadowMap, CVector casterPos, CVector vertDelta) {
    nel3dJNI.CShadowPolyReceiver_render(swigCPtr, this, IDriver.getCPtr(drv), drv, CMaterial.getCPtr(shadowMat), shadowMat, CShadowMap.getCPtr(shadowMap), shadowMap, CVector.getCPtr(casterPos), casterPos, CVector.getCPtr(vertDelta), vertDelta);
  }

  public void renderWithPolyClip(IDriver drv, CMaterial shadowMat, CShadowMap shadowMap, CVector casterPos, CVector vertDelta, SWIGTYPE_p_NLMISC__CPolygon2D poly) {
    nel3dJNI.CShadowPolyReceiver_renderWithPolyClip(swigCPtr, this, IDriver.getCPtr(drv), drv, CMaterial.getCPtr(shadowMat), shadowMat, CShadowMap.getCPtr(shadowMap), shadowMap, CVector.getCPtr(casterPos), casterPos, CVector.getCPtr(vertDelta), vertDelta, SWIGTYPE_p_NLMISC__CPolygon2D.getCPtr(poly));
  }

  public void computeClippedTrisWithPolyClip(CShadowMap shadowMap, CVector casterPos, CVector vertDelta, SWIGTYPE_p_NLMISC__CPolygon2D vertices, SWIGTYPE_p_std__vectorT_NL3D__CRGBAVertex_t destTris, boolean colorUpfacingVertices) {
    nel3dJNI.CShadowPolyReceiver_computeClippedTrisWithPolyClip(swigCPtr, this, CShadowMap.getCPtr(shadowMap), shadowMap, CVector.getCPtr(casterPos), casterPos, CVector.getCPtr(vertDelta), vertDelta, SWIGTYPE_p_NLMISC__CPolygon2D.getCPtr(vertices), SWIGTYPE_p_std__vectorT_NL3D__CRGBAVertex_t.getCPtr(destTris), colorUpfacingVertices);
  }

  public float getCameraCollision(CVector start, CVector end, CShadowPolyReceiver.TCameraColTest testType, float radius) {
    return nel3dJNI.CShadowPolyReceiver_getCameraCollision(swigCPtr, this, CVector.getCPtr(start), start, CVector.getCPtr(end), end, testType.swigValue(), radius);
  }

  public final static class TCameraColTest {
    public final static TCameraColTest CameraColSimpleRay = new TCameraColTest("CameraColSimpleRay");
    public final static TCameraColTest CameraColCylinder = new TCameraColTest("CameraColCylinder");
    public final static TCameraColTest CameraColCone = new TCameraColTest("CameraColCone");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TCameraColTest swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TCameraColTest.class + " with value " + swigValue);
    }

    private TCameraColTest(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TCameraColTest(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TCameraColTest(String swigName, TCameraColTest swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TCameraColTest[] swigValues = { CameraColSimpleRay, CameraColCylinder, CameraColCone };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
